package com.kun.peng.configuration;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Created on 2021/11/15.
 *
 * @author xuebaopeng
 * Description
 */
@Slf4j
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfiguration {


   @Bean("createRestApi1")
     public Docket createRestApi1() {
       Docket docket=new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            //分组名称
            .groupName("自动代码生成")
            .select()
            //这里指定Controller扫描包路径
            .apis(RequestHandlerSelectors.basePackage("com.kun.peng.generator.rest"))
            .paths(PathSelectors.any())
            .build();
             return docket;
       }
    @Bean("createRestApi2")
    public Docket createRestApi2() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                .groupName("系统管理")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.kun.peng.system.rest"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
    @Bean("createRestApi3")
    public Docket createRestApi3() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                .groupName("日志管理")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.kun.peng.logging.rest"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
    /**
     * @author xuebaopeng
     * @description 配置Knife4j页面显示内容
     * @return Docket
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("kun peng 接口文档")
                .description("kun peng 接口文档")
                .version("1.0.0")
                .termsOfServiceUrl("http://localhost:7007/doc.html")
                .contact("xuebaopeng")
                .build();
    }
}
